/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: RabbitMQConfig
 * Author:   pc
 * Date:     2019/9/2 11:07
 * Description: Rabbit配置文件
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.example.rabbitmqdemo.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * 〈功能：〉<br> 
 * 〈Rabbit配置文件〉
 * @author liuhaoran
 * @create 2019/9/2 11:07
 * @since 1.0.0
 */
@Component
public class RabbitMQConfig {
	// 测试队列名称
	private String testQueueName = "demo_queue";
	// 测试交换机名称
	private String testExchangeName = "test_exchange";
	// RoutingKey
	private String testRoutingKey = "test_routing_key";

	/** 创建队列 */
	@Bean
	public Queue testQueue() {
		return new Queue(testQueueName);
	}
	/** 创建交换机 */
	@Bean
	public DirectExchange testExchange() {
		return new DirectExchange(testExchangeName);
	}
	/** 通过routingKey把队列与交换机绑定起来 */
	@Bean
	public Binding testBinding() {
		return BindingBuilder.bind(testQueue()).to(testExchange()).with(testRoutingKey);
	}
}